import request from '../utils/request'
import API from './constants'

/**
 * 登录
 * @param {*} user
 * @returns
 */
export const loginAsync = user => request({
  url: API.SESSIONS_API,
  method: 'POST',
  data: user,
})

/**
 * 获取验证码
 * @returns
 */
export const getCaptcha = () => request({
  url: API.CODE_API,
})

/**
 * 验证码校验
 * @param {*} captcha
 * @returns
 */
export const verifyCaptcha = captcha => request({
  url: API.CODE_API,
  method: 'POST',
  data: {
    captcha,
  },
})

/**
 * 获取用户的角色及权限
 * @returns
 */
export const getUserPermission = () => request({
  url: API.PERMISSION_API,
})
